<?php

namespace app\index\model;

use think\Db;
class BaseModel
{
    public static function selectAll($tablename){
        return Db::table($tablename)->select();
    }
    public static function select($tablename,$idKey,$idValue){
        return Db::table($tablename)->where($idKey,$idValue)->select();
    }
    public static function delete($tablename,$idKey,$idValue){
        return Db::table($tablename)->where($idKey,$idValue)->delete();
    }
    public static function I($key = '', $default = null, $filter = ''){
        if (0 === strpos($key, '|') || false===strpos($key, '|')) {
            return input($key,$default,$filter);
        }else{
            $input = input('');
            $param = explode('|', $key);
            $paramData = [];
            foreach ($param  as $v){
                if (isset($input[$v])){
                    $paramData[$v] = $input[$v];
                }else{
                    $paramData[$v] = null;
                }
            }
            return $paramData;
        }
    }

}